package com.bmf.module.rbac.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bmf.module.rbac.entity.RbacRole;
import com.bmf.module.rbac.mapper.RbacRoleMapper;
import com.bmf.module.rbac.service.RbacRoleService;
import com.bmf.module.rbac.vo.RbacRoleCreateVo;
import com.bmf.module.rbac.vo.RbacRoleResultVo;
import com.bmf.module.rbac.vo.RbacRoleUpdateVo;
import com.bmf.utils.BeanCopyUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (RbacRole)表服务实现类
 *
 * @author makejava
 * @since 2022-12-27 15:33:18
 */
@Service("rbacRoleService")
public class RbacRoleServiceImpl extends ServiceImpl<RbacRoleMapper, RbacRole> implements RbacRoleService {

    @Override
    public List<RbacRoleResultVo> selectAll() {
        List<RbacRole> list = list();
        List<RbacRoleResultVo> rbacRoleResultVos = BeanCopyUtils.copyBeanList(list, RbacRoleResultVo.class);
        return rbacRoleResultVos;
    }

    @Override
    public Integer insert(RbacRoleCreateVo rbacRoleCreateVo) {
        RbacRole rbacRole = BeanCopyUtils.copyBean(rbacRoleCreateVo, RbacRole.class);
        save(rbacRole);
        return rbacRole.getId();
    }

    @Override
    public void update(RbacRoleUpdateVo rbacRoleUpdateVo) {
        RbacRole rbacRole = BeanCopyUtils.copyBean(rbacRoleUpdateVo, RbacRole.class);
        updateById(rbacRole);
    }

    @Override
    public void delete(List<Integer> ids) {
        removeByIds(ids);
    }

    @Override
    public RbacRoleResultVo getOneById(Integer id) {
        RbacRole byId = getById(id);
        return BeanCopyUtils.copyBean(byId,RbacRoleResultVo.class);
    }
}
